home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / sbin / cryptdisks_stop < prev    next >
Encoding:
Text File  |  2011-03-11  |  1.2 KB  |  48 lines

  1. #!/bin/sh
  2.  
  3. # cryptdisks_stop - wrapper around cryptsetup which parses
  4. # /etc/crypttab, just like mount parses /etc/fstab.
  5.  
  6. # Initial code stolen from cryptdisks_start by Jon Dowland <jon@alcopop.org>
  7. # Copyright (C) 2008 by Jonas Meurer <jonas@freesources.org>
  8. # License: GNU General Public License, v2 or any later
  9. # (http://www.gnu.org/copyleft/gpl.html)
  10.  
  11. set -e
  12.  
  13. if [ $# -lt 1 ]; then
  14.     echo "usage: $0 <name>" >&2
  15.     echo >&2
  16.     echo "reads /etc/crypttab and stops the mapping corresponding to <name>" >&2
  17.     exit 1
  18. fi
  19.  
  20. . /lib/cryptsetup/cryptdisks.functions
  21.  
  22. INITSTATE="manual"
  23. DEFAULT_LOUD="yes"
  24.  
  25. if [ -x "/usr/bin/id" ] && [ "$(/usr/bin/id -u)"  != "0" ]; then
  26.     log_warning_msg "$0 needs root privileges"
  27.     exit 1
  28. fi
  29.  
  30. log_action_begin_msg "Stopping crypto disk"
  31.  
  32. count=0
  33. tablen="$(egrep -v "^[[:space:]]*(#|$)" "$TABFILE" | /usr/bin/wc -l)"
  34. egrep -v "^[[:space:]]*(#|$)" "$TABFILE" | while read dst src key opts; do
  35.     count=$(( $count + 1 ))
  36.     if [ "$1" = "$dst" ]; then
  37.         ret=0
  38.         handle_crypttab_line_stop "$dst" "$src" "$key" "$opts" <&3 || ret=$?
  39.     elif [ $count -ge $tablen ]; then
  40.         ret=1
  41.         device_msg "$1" "failed, not found in crypttab"
  42.     else
  43.         continue
  44.     fi
  45.     log_action_end_msg $ret
  46.     exit $ret
  47. done 3<&1
  48.